<p>
  <%=content_tag(:label, l(:label_maximum_files_upload) + ":") %>
  <%=text_field_tag "settings[dmsf_max_file_upload]", @settings["dmsf_max_file_upload"], :size=>10 %><br/>
  (<%=l(:label_default)%>: 0)
  <br/>
  <%= l(:note_maximum_number_of_files_uploaded) %>
</p>

<p>
  <%=content_tag(:label, l(:label_maximum_files_download) + ":") %>
  <%=text_field_tag "settings[dmsf_max_file_download]", @settings["dmsf_max_file_download"], :size=>10 %><br/>
  (<%=l(:label_default)%>: 0)
  <br/>
  <%= l(:note_maximum_number_of_files_downloaded) %>
</p>

<p>
  <%=content_tag(:label, l(:label_file_storage_directory) + ":") %>
  <% 
	storage_dir = @settings["dmsf_storage_directory"].strip
	storage_dir = "#{RAILS_ROOT}/files/dmsf" if storage_dir.blank?
  %>
  <%=text_field_tag "settings[dmsf_storage_directory]", storage_dir, :size=>50 %><br/>
  (<%=l(:label_default)%>: <%="#{RAILS_ROOT}/files/dmsf"%>)
</p>
<% unless File.exists?(storage_dir)
	begin
  		Dir.mkdir(storage_dir)
   	rescue %>
		<p class="warning"><%= l(:error_file_storage_directory_does_not_exist) %></p> 
<%	end 
   end %>
<% testfilename = "#{storage_dir}/test.test"
   if File.exists?(storage_dir)
	begin
		File.open(testfilename, "wb") do |file|
		end
   	rescue %>
		<p class="warning"><%= l(:error_file_can_not_be_created) %></p>
<%	ensure
		File.delete(testfilename) if File.exists?(testfilename)
	end 
   end %>

<p>
  <%=content_tag(:label, l(:label_default_notifications) + ":") %>
  <%=select_tag("settings[dmsf_default_notifications]", 
		options_for_select([
				[l(:select_option_deactivated), nil], 
				[l(:select_option_activated), "1"]], 
				:selected => @settings["dmsf_default_notifications"])) %><br/>
  (<%=l(:label_default)%>: <%=l(:select_option_deactivated)%>)
</p>

<p>
  <%=content_tag(:label, l(:label_zip_names_encoding) + ":") %>
  <%=text_field_tag "settings[dmsf_zip_encoding]", @settings["dmsf_zip_encoding"], :size=>50 %><br/>
  (<%=l(:label_default)%>: utf-8)
  <br/>
  <%= l(:note_zip_names_encoding_iconv) %>
</p>
<% unless @settings["dmsf_zip_encoding"].blank? || @settings["dmsf_zip_encoding"].downcase == "utf-8"
	begin
  		Iconv.conv(@settings["dmsf_zip_encoding"], "utf-8", "test")
   	rescue %>
		<p class="warning"><%= l(:error_wrong_zip_encoding) %></p> 
<%	end 
   end %>

<hr />
<% begin
  	require 'xapian'
  	xapian_disabled = false
   rescue LoadError	%>
	<p class="warning"><%= l(:warning_xapian_not_available) %></p> 
<% 	xapian_disabled = true
   end %>

<p>
  <%=content_tag(:label, l(:label_index_database) + ":") %>
  <%=text_field_tag 'settings[dmsf_index_database]', @settings['dmsf_index_database'], :disabled => xapian_disabled, :size=>50 %><br/>
  (<%=l(:label_default)%>: <%="#{RAILS_ROOT}/files/dmsf_index"%>)
</p>

<p>
  <%=content_tag(:label, l(:label_stemming_language) + ":") %>
  <%=text_field_tag 'settings[dmsf_stemming_lang]', @settings['dmsf_stemming_lang'], :disabled => xapian_disabled %><br/>
  (<%=l(:label_default)%>: english )<br/>
  <br/>
  <%=l(:note_possible_values)%>: danish dutch english finnish french german german2 hungarian italian kraaij_pohlmann lovins norwegian porter portuguese romanian russian spanish swedish turkish (<%=l(:note_pass_none_to_disable_stemming)%>)
</p>

<p>
  <%=content_tag(:label, l(:label_stem_strategy) + ":")%>
  <%=radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_NONE', @settings['dmsf_stemming_strategy'] == 'STEM_NONE', :disabled => xapian_disabled, :checked=>true  %> <%=l(:option_stem_none)%><br>
  <%=radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_SOME', @settings['dmsf_stemming_strategy'] == 'STEM_SOME', :disabled => xapian_disabled  %> <%=l(:option_stem_some)%><br>
  <%=radio_button_tag 'settings[dmsf_stemming_strategy]', 'STEM_ALL', @settings['dmsf_stemming_strategy'] == 'STEM_ALL', :disabled => xapian_disabled  %> <%=l(:option_stem_all)%><br>
  <br/>
  <%=l(:label_stemming_description)%>:
  <br>
    STEM_NONE: <%=l(:note_do_not_stem)%><br>
    STEM_SOME: <%=l(:note_stem_some)%><br>
    STEM_ALL: <%=l(:note_stem_all)%><br>
  <br/>
  <%=l(:note_stemming_applied)%><br>
</p>
